<template>
  <el-drawer
    :visible="drawer"
    :show-close="false"
    @close="handleClose"
    size="35.5%"
    class="detailDrawer"
  >
    <div class="drawerWrapper">
      <div v-if="activeKey == '1'" class="wrap">
        <el-tabs v-model="activeName" ref="tabs" @tab-click="handleClick">
          <el-tab-pane label="基本信息" name="1"></el-tab-pane>
          <el-tab-pane label="交易信息" name="2"></el-tab-pane>
          <!-- <el-tab-pane label="退款信息" name="3"></el-tab-pane> -->
        </el-tabs>

        <div v-if="activeName == '1'" class="tabContnet">
          <ul class="list">
            <li class="item">
              <div class="tit">创建时间</div>
              <div class="desc">
                {{ info.gmtCreated ? info.gmtCreated : "-" }}
              </div>
            </li>
            <li class="item">
              <div class="tit">商户订单号</div>
              <div class="desc">
                {{ info.payformNo ? info.payformNo : "-" }}
              </div>
              <div
                v-if="info.payformNo"
                style="margin-left: 32px; color: #03bfc6; cursor: pointer"
              >
                <i
                  class="el-icon-document-copy"
                  @click="copyAppId(info.payformNo)"
                ></i>
              </div>
            </li>
            <li class="item">
              <div class="tit">云尘付流水号</div>
              <div class="desc">
                {{ info.innerPayformNo ? info.innerPayformNo : "-" }}
              </div>
              <div
                v-if="info.innerPayformNo"
                style="margin-left: 32px; color: #03bfc6; cursor: pointer"
              >
                <i
                  class="el-icon-document-copy"
                  @click="copyAppId(info.innerPayformNo)"
                ></i>
              </div>
            </li>
            <li class="item">
              <div class="tit">充值对象</div>
              <div class="desc">
                {{ info.memberName ? info.memberName : "-" }}
              </div>
            </li>
            <li class="item">
              <div class="tit">充值金额/元</div>
              <div class="desc">
                {{ info.fmtActualAmount ? info.fmtActualAmount : "-" }}
              </div>
            </li>
          </ul>
        </div>
        <div v-if="activeName == '2'" class="tabContnet">
          <ul class="list">
            <li class="item">
              <div class="tit">交易时间</div>
              <div class="desc">
                {{
                  info.businessPayRes.payTime
                    ? info.businessPayRes.payTime
                    : "-"
                }}
              </div>
            </li>
            <li class="item">
              <div class="tit">渠道流水号</div>
              <div class="desc">
                {{
                  info.businessPayRes.thirdOrderNo
                    ? info.businessPayRes.thirdOrderNo
                    : "-"
                }}
              </div>
              <div
                v-if="info.businessPayRes.thirdOrderNo"
                style="margin-left: 32px; color: #03bfc6; cursor: pointer"
              >
                <i
                  class="el-icon-document-copy"
                  @click="copyAppId(info.businessPayRes.thirdOrderNo)"
                ></i>
              </div>
            </li>
            <li class="item">
              <div class="tit">支付渠道</div>
              <div class="desc">
                {{
                  info.businessPayRes.payformChannel
                    ? info.businessPayRes.payformChannel
                    : "-"
                }}
              </div>
            </li>
            <li class="item">
              <div class="tit">充值手续费/元</div>
              <div class="desc">
                {{
                  info.businessPayRes.fmtFeeAmount
                    ? info.businessPayRes.fmtFeeAmount
                    : "-"
                }}
              </div>
            </li>
            <li class="item">
              <div class="tit">充值状态</div>
              <div class="desc">
                {{
                  info.businessPayRes.payStatusName
                    ? info.businessPayRes.payStatusName
                    : "-"
                }}
              </div>
            </li>
          </ul>
        </div>
        <!-- <div v-if="activeName == '3'" class="tabContnet">
            <ul class="list">
              <li class="item">
                <div class="tit">退款情况</div>
                <div class="desc">
                  {{ info.businessRefundRes.refundState ? info.businessRefundRes.refundState : "-" }}
                </div>
              </li>
              <li class="item">
                <div class="tit">退款时间</div>
                <div class="desc" v-if="info.businessRefundRes.refundState!='无退款'&&info.businessRefundRes.refundState">
                  {{ info.businessRefundRes.fmtRefundTotalAmount ? info.businessRefundRes.fmtRefundTotalAmount : "-" }}
                </div>
                <div class="desc" v-else>-</div>
              </li>
              <li class="item">
                <div class="tit">退款金额/元</div>
                <div class="desc" v-if="info.businessRefundRes.refundState!='无退款'&&info.businessRefundRes.refundState">
                  {{ info.businessRefundRes.fmtRefundTotalAmount ? info.businessRefundRes.fmtRefundTotalAmount : "-" }}
                </div>
                <div class="desc" v-else>-</div>
              </li>
            </ul>
          </div> -->
      </div>
    </div>
  </el-drawer>
</template>

<script>
export default {
  props: {
    drawer: {
      type: Boolean,
    },
    info: {
      type: Object,
      default: () => ({}),
    },
    activeKey: {
      type: String,
      default: "1",
    },
    width: {
      type: String,
      default: "140px",
    },
  },
  components: {},
  data() {
    return {
      resetKey: false,
      activeName: "1",
    };
  },
  methods: {
    handleClose() {
      this.$emit("update:drawer", false);
      this.activeName = "1";
    },
    handleClick() {
      this.resetActivePosition(this.$refs.tabs.$el);
    },
    resetActivePosition($el) {
      this.$nextTick(() => {
        const activeEl = $el.querySelector(".el-tabs__item.is-active");
        const lineEl = $el.querySelector(".el-tabs__active-bar");
        const style = getComputedStyle(activeEl);
        const pl = style.paddingLeft.match(/\d+/)[0] * 1;
        const pr = style.paddingRight.match(/\d+/)[0] * 1;
        const w = style.width.match(/\d+/)[0] * 1;
        lineEl.style.transform =
          "translateX(" + (activeEl.offsetLeft + pl) + "px)";
        lineEl.style.width = w - pl - pr + "px";
      });
    },
    copyAppId(value) {
      const input = document.createElement("input"); // 创建input对象
      input.value = value; // 设置复制内容
      document.body.appendChild(input); // 添加临时实例
      input.select(); // 选择实例内容
      document.execCommand("Copy"); // 执行复制
      document.body.removeChild(input); // 删除临时实例
      this.$message.success("复制成功！");
    },
  },
};
</script>

<style lang="scss" scoped>
.drawerWrapper {
  padding: 0 50px;
}

.tabContnet {
  margin-top: 30px;
  .item {
    display: flex;
    align-items: flex-start;
    min-height: 20px;
    // line-height: 40px;
    margin-bottom: 20px;
    div {
      // display: inline-block;
      &.tit {
        min-width: 88px;
        font-size: 14px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #869daa;
        margin-right: 26px;
      }
      &.desc {
        display: flex;
        // justify-content: space-around;
        font-size: 14px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #1d1c1c;
        span {
          display: inline-block;
          margin-right: 10px;
          &.hidText {
            display: inline-block;
            width: 230px;
            overflow: hidden; //溢出隐藏
            white-space: nowrap; //禁止换行
            text-overflow: ellipsis; //...
          }
          &.highCol {
            color: #03bfc6;
          }
        }
      }
    }
  }
  .item-table {
    margin-top: 17px;
    :deep(.el-table .el-table__header-wrapper .el-table__cell) {
      height: 34px;
    }
    :deep(.el-table .el-table__body-wrapper .el-table__cell) {
      height: 34px;
    }
  }
}

:deep(.el-tabs__item) {
  width: 72px !important;
  font-size: 18px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  margin-right: 40px;
}
:deep(.el-tabs__active-bar) {
  top: unset;
  bottom: 0;
  height: 1px;
}
</style>
